﻿﻿<%@ page language="java" contentType="text/html; charset=UTF-8"
		  pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String lang = (String)request.getAttribute("lang");
	String dhxskin = "dhx_skyblue";
	String bpmpCtx = (String)request.getAttribute("bpmpCtx");
	String fmdCtx = (String)request.getAttribute("fmdCtx");
	String dver = (String)request.getAttribute("productionVersion");
	String resloc = (String)request.getAttribute("cdnfmd");
%>
<!DOCTYPE html>
<html>
<head>
<title><%="zh".equalsIgnoreCase(lang) ? "表单打印预览" : "Form Printing Preview"%></title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">

<style type="text/css">
/* 解决Angular 初始化闪烁 */
.ng-cloak1{
	visibility:hidden !important;
}
</style>

<link rel="shortcut icon" href="<%=resloc%>/favicon.ico" />
<link href="<%=resloc%>/static/formskins/bootstrap-blue/css/bootstrap.css?<%=dver%>" rel="stylesheet">
<link href="<%=resloc%>/static/formskins/bootstrap-blue/css/custom.css?<%=dver%>" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="<%= resloc %>/static/css/jqueryui1.10.4/jquery-ui.css?<%=dver%>">
<link rel="stylesheet" type="text/css" href="<%= resloc %>/static/js/jquery-ui1.10.4/jquery.ui.theme.css?<%=dver%>">
<link rel="stylesheet" href="<%=resloc%>/static/css/dhtmlx3/dhtmlx_classic.css?<%=dver%>">

<link href="<%=resloc%>/static/formskins/bootstrap-blue/css/timepicker.css?<%=dver%>" rel="stylesheet">
<link href="<%=resloc%>/static/formskins/bootstrap-blue/css/bootstrap-datetimepicker.min.css?<%=dver%>" rel="stylesheet">
<link href="<%=resloc%>/static/formskins/bootstrap-blue/css/font-awesome.css?<%=dver%>" rel="stylesheet">
<link href="<%=resloc%>/static/formskins/bootstrap-blue/css/printer.css?<%=dver%>" rel="stylesheet">

<script src="<%=resloc%>/static/js/jquery/jquery-1.10.2.js?<%=dver%>" type="text/javascript"></script>
<script src="<%=resloc%>/static/js/jquery/jquery.tipsy.js?<%=dver%>"></script>
<script src="<%=resloc%>/static/js/jquery-ui1.10.4/jquery-ui.js?<%=dver%>" type="text/javascript"></script>
<script type="text/javascript" src="<%= resloc %>/static/js/3rdpartyother/angular-all.min.js?<%=dver%>"></script>

<script src="<%=resloc%>/static/js/dhtmlx3/dhtmlx.js?<%=dver%>"></script>
<script src="<%=resloc%>/static/js/dhtmlx3/ext/dhxgrid.js?<%=dver%>"></script>
<script src="<%=resloc%>/static/js/dhtmlx3/ext/excell_types.js?<%=dver%>"></script>
<script src="<%=resloc%>/static/js/dhtmlx3/ext/validator.js?<%=dver%>"></script>
<script src="<%=resloc%>/static/js/dhtmlx3/ext/dhx_i18n_<%=lang%>.js?<%=dver%>"></script>
<script src="<%=resloc%>/static/js/3rdpartyother/json2.js?<%=dver%>"></script>

<script src="<%=resloc%>/static/formskins/bootstrap-blue/js/bootstrap.min.js?<%=dver%>" type="text/javascript"></script>
<script src="<%=resloc%>/static/formskins/bootstrap-blue/js/bootstrap-datetimepicker.js?<%=dver%>" type="text/javascript"></script>
<script src="<%=resloc%>/static/formskins/bootstrap-blue/js/bootstrap-timepicker.js?<%=dver%>" type="text/javascript"></script>
<script src="<%=resloc%>/static/formskins/bootstrap-blue/js/locales/bootstrap-datetimepicker.zh-CN.js?<%=dver%>" type="text/javascript"></script>

</head>
<body>

	<nav class="navbar navbar-default navbar-fixed-top" role="navigation" style="min-width:345px;padding-top: 7px;">
		<!-- <div class="navbar-header">
			<a class="navbar-brand" href="javascript:void(0)">任务操作</a>
		</div> -->
		<div>
			
		</div>
	</nav>
	<div class="tableTabDiv">
		<ul id="navTab" class="nav nav-tabs navClear">
			<li class="active"><a href="#tabbody_1" data-toggle="tab" onclick="changeTab(this,'0')">主表单</a></li>
			<!-- <li><a href="#tabbody_2" data-toggle="tab" onclick="changeTab(this,'1')">附件</a></li>
			<li><a href="#tabbody_3" data-toggle="tab" onclick="changeTab(this,'2')">历史</a></li>
			<li><a href="#tabbody_4" data-toggle="tab" onclick="changeTab(this,'3')">流程图</a></li> -->
		</ul>
	</div>
	<div id="main" ng-controller="datactx">
		<%-- <% String formfile = (String)request.getAttribute("formfile");
		   if (formfile!=null && formfile.trim().length()>0) {%>
		   <jsp:include page="<%=formfile%>" ></jsp:include>
		<%} %> --%>
		<!-- <ul id="navTab" class="nav nav-tabs navClear">
			<li class="active"><a href="#tabbody_1" data-toggle="tab" onclick="changeTab(this,'0')">主表单</a></li>
			<li><a href="#tabbody_2" data-toggle="tab" onclick="changeTab(this,'1')">附件</a></li>
			<li><a href="#tabbody_3" data-toggle="tab" onclick="changeTab(this,'2')">历史</a></li>
			<li><a href="#tabbody_4" data-toggle="tab" onclick="changeTab(this,'3')">流程图</a></li>
		</ul> -->
		<div id="navTabContent" class="tab-content">
			<div class="tab-pane fade in active" id="tabbody_1">
				<% String formfile = (String)request.getAttribute("formfile");
		        if (formfile!=null && formfile.trim().length()>0) {%>
		        <jsp:include page="<%=formfile%>" ></jsp:include>
		        <%} %>
			</div>
			<div class="tab-pane fade" id="tabbody_2">
				<p>系统预留附件页面</p>
			</div>
			<div class="tab-pane fade" id="tabbody_3">
				<p>系统预留历史页面</p>
			</div>
			<div class="tab-pane fade" id="tabbody_4">
				<p>系统预留流程图页面</p>
			</div>
		</div>
	</div>

<script type="text/javascript">
var ctxpath = '<%=path%>';
var fmdCtx = '<%=fmdCtx%>';
var resloc = '<%=resloc%>';
var lang = '<%=lang%>';
var imagepath = resloc + '/static/images/';
dhtmlx.image_path = resloc + '/static/css/dhtmlx3/imgs/';
dhx_skin = "<%=dhxskin%>";

$(function() {
	$(".panel-heading").click(function(e){
		$(this).next().toggle();
		var hide = $(this).next().is(":hidden");
		var elems = $(this).parent().nextAll('.panel');
		for (var i in elems) {
			if($(elems[i]).find('.panel-heading').length==0) {
				hide ? $(elems[i]).hide() : $(elems[i]).show();
			} else {
				break;
			}
		};
		if(hide){
			$(this).find("h3").find("span").removeClass("spanCaretBottom");
			$(this).find("h3").find("span").addClass("spanCaretLeft");
		}else{
			$(this).find("h3").find("span").removeClass("spanCaretLeft");
			$(this).find("h3").find("span").addClass("spanCaretBottom");
		}
	});
});

function doSubmit() {
	console.log("datactx.b=\n\n"+JSON.stringify(datactx.b));
	fmdf.saveData(fmdCtx, "test_tsid");
}

function doSave() {
	console.log("datactx.b=\n\n"+JSON.stringify(datactx.b));
	fmdf.saveData(fmdCtx, "test_tsid");
}

$(document).ready(function(){
	fmdf.getData(ctxpath, fmdCtx, "test_tsid", document.getElementById('main'));
});


//GET方式访问一个url，并取得JSON数据
//do get to an url and get data
function doGetAsyncJson(url, callbackFunc, errFunc) {
	return jQuery.ajax({
		url : encodeURI(url),
		async : true,
		cache : false,
		type : "GET",
		dataType : "json",
		success : function(_data){
			if (typeof(callbackFunc)=="function") {
				callbackFunc(_data);
			}
		},
		error: (typeof(errFunc) == "function") ? errFunc : function(xhr, textstate, errthr) {
			fmdf.alert("error", "对不起，读取数据失败！请联系系统管理人员！Error: [" + textstate + "]: " + errthr)
		}
	});
}

//GET方式访问一个url，并取得JSON数据
//do get to an url and get data
function doGetSyncJson(url, inputData, errFunc) {
	var rtndata = null;
	var args = {
			url : encodeURI(url),
			async : false,
			cache : false,
			type : "GET",
			dataType : "json",
			success : function (data) {
				rtndata = data;
			},
			error: (typeof(errFunc) == "function") ? errFunc : function(xhr, textstate, errthr) {
				fmdf.alert("error", "对不起，读取数据失败！请联系系统管理人员！Error: [" + textstate + "]: " + errthr)
			}
		};
	inputData && (args.data = inputData);
	jQuery.ajax(args);
	return rtndata;
}

//POST方式访问一个url，并取得JSON数据
//post form data to an url and get data
function doPostSyncJson(url, inputData, errFunc) {
	var rtndata = null;
	$.ajax({
		contentType:'application/x-www-form-urlencoded',
		url : encodeURI(url),
		async : false,
		cache : false,
		type : "POST",
		data : inputData,
		dataType : "json",
		success : function (data) {
			rtndata = data;
		},
		error: (typeof(errFunc) == "function") ? errFunc : function(xhr, textstate, errthr) {
			fmdf.alert("error", "对不起，读取数据失败！请联系系统管理人员！Error: [" + textstate + "]: " + errthr)
		}
	});
	return rtndata;
}
function doPostAsyncJson(url, inputData, callbackFunc, errFunc) {
	return jQuery.ajax({
		url: encodeURI(url),
		async: true,
		cache: false,
		type: "POST",
		data: inputData,
		dataType: "json",
		success: function(_data) {
			if (typeof(callbackFunc) == "function") {
				callbackFunc(_data)
			}
		},
		//complete: fm_checkSession,
		error: (typeof(errFunc) == "function") ? errFunc : function(xhr, textstate, errthr) {
			fmdf.alert("error", "对不起，读取数据失败！请联系系统管理人员！Error: [" + textstate + "]: " + errthr)
		}
	})
}
function changeTab(obj,num){
	$(obj).parent().parent().find("li").removeClass("active");
    $(obj).parent().addClass("active");
    var showTab=$(obj).attr("href");
    $("#navTabContent").find("div").removeClass("in active");
    $(showTab).addClass("in active");
    index=parseInt(num);
    //alert("index==="+index);
}

function doClose() {
	if (window.opener) {
		if (navigator.appName == 'Microsoft Internet Explorer') {
			window.opener = 'whatever';
			window.open('', '_parent', '');
			window.close()
		} else {
			window.open('', '_self', '');
			window.close()
		}
	} else {
		if (navigator.appName == 'Microsoft Internet Explorer') {
			window.opener = null;
			window.open('', '_self', '');
			window.close()
		} else {
			window.open('', '_parent', '');
			self.close()
		}
	}
}
</script>
<script type="text/javascript">  
//手机端滑动屏幕时事件
  //全局变量，触摸开始位置  
  var startX = 0, startY = 0;  
  var index=0; 
  var direction="left";
  var time;
  //touchstart事件  
  function touchSatrtFunc(evt) {  
      try  
      {  
          //evt.preventDefault(); //阻止触摸时浏览器的缩放、滚动条滚动等  

          var touch = evt.touches[0]; //获取第一个触点  
          var x = Number(touch.pageX); //页面触点X坐标  
          var y = Number(touch.pageY); //页面触点Y坐标  
          //记录触点初始位置  
          startX = x;  
          startY = y; 
          time=new Date();
      }  
      catch (e) {  
          alert('touchSatrtFunc：' + e.message);  
      }  
  }  

  //touchmove事件
  function touchMoveFunc(evt) { 
	//当屏幕有多个touch或者页面被缩放过，就不执行move操作
	　if(evt.targetTouches.length > 1 || evt.scale && evt.scale !== 1) return;
      try  
      {  
          //evt.preventDefault(); //阻止触摸时浏览器的缩放、滚动条滚动等  
          var touch = evt.touches[0]; //获取第一个触点  
          x = Number(touch.pageX); //页面触点X坐标  
          y = Number(touch.pageY); //页面触点Y坐标  

          //判断滑动方向  
          var isScrolling = Math.abs(x - startX) < Math.abs(y-startY) ? 1:0;    //isScrolling为1时，表示纵向滑动，0为横向滑动
          if (isScrolling === 0) {  //左右滑动
        	  event.preventDefault(); //阻止触摸事件的默认行为，即阻止滚屏
               if(x - startX > 10){//向右滑
            	   direction="right";
               }else if(x - startX < -10){//向左滑
            	   direction="left";
               } 
          }else{
        	  direction="vertical";
          }  
          /* if (y - startY != 0) {  //上下滑动
              
          }  */ 
      }  
      catch (e) {  
          alert('touchMoveFunc：' + e.message);  
      }  
  }  

  //touchend事件  
  function touchEndFunc(evt) {  
      try {  
          //evt.preventDefault(); //阻止触摸时浏览器的缩放、滚动条滚动等
          var duration = (new Date()) - time; //滑动的持续时间
       	　if(Number(duration) > 10){
        		if(direction=="right"){
                  	 if(parseInt(index)>0){
                  		 $("#navTab").find("li").removeClass("active");
                  		 $("#navTabContent").find(".tab-pane").removeClass("in active");
                  		 //var showTabLi=$("#navTab li")[index-1];
                  		 $("#navTab").find("li").eq(parseInt(index)-1).addClass("active");
                  		 $("#navTabContent").find(".tab-pane").eq(parseInt(index)-1).addClass("in active");
                  		 index=parseInt(index)-1;
                  	 }
                 }else if(direction=="left"){
                  	 if(parseInt(index)<3){
                  		/*  $("#navTab").find("li").removeClass("active");
                  		 $("#navTabContent").find(".tab-pane").removeClass("in active");
                  		 //var showTabLi=$("#navTab li")[index+1];
                  		 $("#navTab").find("li").eq(parseInt(index)+1).addClass("active");
                  		 $("#navTabContent").find(".tab-pane").eq(parseInt(index)+1).addClass("in active");
                  		 index=parseInt(index)+1; */
                  	 }
                 }
       	　}
          
      }  
      catch (e) {  
          alert('touchEndFunc：' + e.message);  
      }  
  }  

  //绑定事件  
  function bindEvent(id) {  
      document.getElementById(id).addEventListener('touchstart', touchSatrtFunc, false);  
      document.getElementById(id).addEventListener('touchmove', touchMoveFunc, false);  
      document.getElementById(id).addEventListener('touchend', touchEndFunc, false);  
  }  
//解绑事件
function removeEvent(id) {  
      document.getElementById(id).removeEventListener('touchstart', touchSatrtFunc, false);  
      document.getElementById(id).removeEventListener('touchmove', touchMoveFunc, false);  
      document.getElementById(id).removeEventListener('touchend', touchEndFunc, false);  
  } 
  
  //判断是否支持触摸事件  
  function isTouchDevice() {  
      //navigator.appVersion;//返回浏览器版本  
      try {  
          document.createEvent("TouchEvent");  
          //alert("支持TouchEvent事件！");  
          bindEvent("navTabContent"); //绑定事件  
      }  
      catch (e) {  
          //alert("不支持TouchEvent事件！" + e.message);  
      }  
  }  

  window.onload = isTouchDevice;

</script>
</body>
</html>